
/******1.*验证***/

//----H5

/***********用户名输入验证**********/
/*uname.onblur=function(){
	if(this.validity.valueMissing){
		var msg ='用户名密码不能为空';
		this.nextElementSibling.innerHTML = msg;
		this.nextElementSibling.className='help-block bg-danger';
		this.setCustomValidity(msg);
	}else if(this.validity.tooShort){
		 var msg='用户名不能少于6位!';
		 this.nextElementSibling.innerHTML=msg;
		 this.nextElementSibling.className="help-block bg-danger";
		 this.setCustomValidity(msg);
	}else if(this.validity.tooLong){
		 var msg='用户名不能多于9位';
		 this.nextElementSibling.innerHTML=msg;
		 this.nextElementSibling.className="help-block bg-danger";
		 this.setCustomValidity(msg);
	}else{
		 this.nextElementSibling.innerHTML='用户名输入合法';
		 this.nextElementSibling.className='help-block bg-success';
		 this.setCustomValidity('');
	}
}*/
//手机号
phone.onblur= function () {
	var phone = document.getElementById('phone').value;
	
	if (this.validity.valueMissing) {
		this.nextElementSibling.innerHTML = '手机号不能为空';
		this.nextElementSibling.className = 'help-block bg-danger';
		return false;
	} else if (!(/^1[3456789]\d{9}$/.test(phone))) {
		this.nextElementSibling.innerHTML = '手机号格式不正确';
		this.nextElementSibling.className = 'help-block bg-danger';
		return false;
	} else {
		this.nextElementSibling.innerHTML = '手机号输入正确';
		this.nextElementSibling.className = 'help-block bg-success';
	}
}
/*******密码********/
$('#upwd').blur(function () {
	var val = document.getElementById('upwd').value;
	if (val === ""){
		this.nextElementSibling.innerHTML='密码不能为空';
		this.nextElementSibling.className = 'help-block bg-danger';
		return false;
	}else if(this.validity.tooShort){
		this.nextElementSibling.innerHTML='密码不能少于6位';
		this.nextElementSibling.className = 'help-block bg-danger';
		return false;
	}else {
		 this.nextElementSibling.innerHTML='密码输入正确';
		 this.nextElementSibling.className='help-block bg-success';
	}

})
//-------------->用户名和密码此处必须在html中写required不然不填不走第一个if（配套）


//---

$('#uname').blur(function () {

	var uname = document.getElementById('uname');
	 var val=uname.value;
	if(val===""){
		this.nextElementSibling.innerHTML="用户名不能为空"
		this.nextElementSibling.className = 'help-block bg-danger';
		return false;
	}else if(val.length<3||val.length>6){
		 this.nextElementSibling.innerHTML=" 用户名在3- 6位";
		this.nextElementSibling.className = 'help-block bg-danger';
		return false;
	}else{
		 this.nextElementSibling.innerHTML="用户名输入正确";
		 this.nextElementSibling.className='help-block bg-success';
	}
	
})
//对邮箱进行验证
$('#email').blur(function () {
	var email = document.getElementById('email').value;
	var reg =/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
	
	 if (!reg.test(email)){
			this.nextElementSibling.innerHTML='邮箱格式不正确';
			this.nextElementSibling.className='help-block bg-danger';
		 this.setCustomValidity('请输入xx@xx.cn/com');
		 return false;
	 }else{
			this.nextElementSibling.innerHTML='邮箱格式正确';
			this.nextElementSibling.className='help-block bg-success';
			this.setCustomValidity('');
	 }
})

/****2.异步提交注册******/





























